#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Author: season
# @File  : db_router.py
# @Date  : 2018/8/31
# @Desc  : 读写处理


# 配置路由，去连数据库，hair_star
class DatabaseAppsRouter(object):

    def db_for_read(self, model, **hints):
        if model._meta.app_label.startswith('hair_'):
            return 'hair_star'
        return None

    def db_for_write(self, model, **hints):
        if model._meta.app_label.startswith('hair_'):
            return 'hair_star'
        return None


"""
 模型优化
 class Href(models.Model):
    name = models.CharField(max_length=100)
    path = models.CharField(max_length=100)
 
    class Meta:
        app_label = 'hair_star'
"""
